{% extends 'layout.html' %}
{% load static%}
{% load permission %}
{% block content %}
    <div style="margin-bottom: 5px;">
<!--        <a class="btn btn-success" href="{% url 'policy_add' %}">-->
<!--            <span class="glyphicon glyphicon-plus-sign"></span> 新建-->
<!--        </a>-->
        {% add_permission request 'policy_add' %}
    </div>
    <table class="table table-bordered">
        <thead>
            <tr>
                <th>ID</th>
                <th>数量</th>
                <th>价格</th>
                {% if request|has_permission:"policy_edit, policy_delete" %}
                <th>操作</th>
                {% endif %}
            </tr>
        </thead>
        <tbody>
        {% for row in pager.queryset %}
            <tr row-id="{{ row.id }}">
                <td>{{ row.id }}</td>
                <td>{{ row.count }} </td>
                <td>{{ row.price }}</td>
                {% if request|has_permission:"policy_edit, policy_delete" %}
                <td>
<!--                    <a href="{% url 'policy_edit' pk=row.id %}" class="btn btn-primary btn-xs">编辑</a>-->
<!--                    <a cid="{{ row.id }}" class="btn btn-danger btn-xs btn-delete ">删除</a>-->
                    {% edit_permission request 'policy_edit' pk=row.id %}
                    {% delete_permission request 'policy_delete' pk=row.id %}
                </td>
                {% endif %}
            </tr>
        {% endfor %}
      </tbody>
    </table>

    <ul class="pagination">
        {{ pager.html }}
    </ul>

    {% include 'include/delete_modal.html' %}

{% endblock %}

{% block js %}
    <script src="{% static 'js/delete_modal.js' %}"></script>
    <script>
    let DELETE_ID;
    let DELETE_URL = "{% url 'policy_delete' %}";

    </script>

{% endblock %}